package utils;

import java.util.ArrayList;
import java.util.List;

public class HamiltonCycle {
    private int n;
    private List<Integer> path;

    public HamiltonCycle(EulerCycle euler) {
        boolean[] visited;
        n = euler.getN();
        path = new ArrayList<Integer>();
        visited = new boolean[n + 1];
        for (int i = 1; i <= n; i++)
            visited[i] = false;
        int start = 0;
        for (int node: euler.getPath()) {
            if (start == 0)
                start = node;
            if (!visited[node]) 
                path.add(node);
            visited[node] = true;
        }
        path.add(start);
        System.out.println("Complete Hamilton !!!");
    }

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }

    public List<Integer> getPath() {
        return path;
    }

    public void setPath(List<Integer> path) {
        this.path = path;
    }
    
    public void displayHamiltonCycle() {
        for (int node: path) 
            System.out.print(node + " -> ");
        System.out.println();
    }
}
